package com.zhanglu.fun.services.website.forum.post;

import com.zhanglu.fun.services.website.bean.request.ForumPostRequest;
import com.zhanglu.fun.services.website.common.ResultResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhanglu
 * @description
 * @date 2017/9/24 15:04
 */
@RestController
@Slf4j
public class PostRouter {
    @Autowired
    private PostService forumPostService;

    @GetMapping("forum/posts/{threadId}")
    public ResultResponse getForumPostsByThreadId(@PathVariable(value = "threadId", required = false) Long threadId) {
        log.info("getForumPostsByThreadId receive param:[threadId is:{}]", threadId);
        return forumPostService.getForumPostsByThreadId(threadId);
    }

    @PutMapping("forum/post")
    public ResultResponse addForumPost(ForumPostRequest post) {
        return forumPostService.addForumPost(post);
    }
}
